package com.scalar.forecast.systemprefs.actioncommands;

import com.scalar.forecast.actionCommands.ActionCommand;
import com.scalar.forecast.commons.Constants;

import com.scalar.forecast.commons.logger.Logger;
import com.scalar.forecast.commons.logger.LoggerManager;

/**
 * @author  Basha
 * @version 1.0
 */

public class SystemPreferencesActionCommandFactory implements Constants
{
    private static SystemPreferencesActionCommandFactory sPfactory;

    private static final Logger LOGGER = LoggerManager.getLogger( SystemPreferencesActionCommandFactory.class );

    public synchronized static SystemPreferencesActionCommandFactory getInstance()
    {
        if( sPfactory == null )
        {
            sPfactory = new SystemPreferencesActionCommandFactory();
        }
        return sPfactory;
    }

    private SystemPreferencesActionCommandFactory()
    {
    }

    /**
     * Returns the ActionCommand Class that implements businnes logic for the given action
     *
     * @param action
     * @return
     */
    public static ActionCommand getActionCommand( String action )
    {
        if(  ACTION_MODIFY.equalsIgnoreCase( action ) )
        {
            return new SystemPreferencesModifyCommand();
        }

        if( ACTION_SAVE.equalsIgnoreCase( action ) )
        {
            return new SystemPreferencesSaveCommand();
        }

        LOGGER.log( Logger.DEBUG, "In SystemPreferencesActionCommandFactory " );
        return null;
    }
}
